.markdown-message {
  line-height: 1.6;
  word-wrap: break-word;
}

.markdown-message p {
  margin: 0.5em 0;
}

.markdown-message p:first-child {
  margin-top: 0;
}

.markdown-message p:last-child {
  margin-bottom: 0;
}

.markdown-message h1,
.markdown-message h2,
.markdown-message h3,
.markdown-message h4,
.markdown-message h5,
.markdown-message h6 {
  margin: 1em 0 0.5em 0;
  font-weight: 600;
  line-height: 1.25;
}

.markdown-message h1 {
  font-size: 1.5em;
  border-bottom: 1px solid #333;
  padding-bottom: 0.3em;
}

.markdown-message h2 {
  font-size: 1.3em;
  border-bottom: 1px solid #333;
  padding-bottom: 0.3em;
}

.markdown-message h3 {
  font-size: 1.15em;
}

.markdown-message ul,
.markdown-message ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.markdown-message li {
  margin: 0.25em 0;
}

.markdown-message blockquote {
  margin: 0.5em 0;
  padding: 0 1em;
  border-left: 4px solid #4a9eff;
  color: #aaa;
  background: rgba(74, 158, 255, 0.1);
  border-radius: 4px;
}

.markdown-message hr {
  margin: 1em 0;
  border: none;
  border-top: 1px solid #333;
}

.markdown-inline-code {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
  font-size: 0.9em;
  color: #e06c75;
}

.markdown-code-block {
  margin: 0.5em 0;
  padding: 0;
  background: #1e1e1e;
  border-radius: 6px;
  overflow-x: auto;
  border: 1px solid #333;
}

.markdown-code-block code {
  display: block;
  padding: 1em;
  overflow-x: auto;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
  font-size: 0.9em;
  line-height: 1.5;
  color: #d4d4d4;
  background: transparent;
}

/* 确保 highlight.js 样式正确应用 */
.markdown-code-block code.hljs {
  background: #1e1e1e;
  padding: 1em;
}

.markdown-code-block pre {
  margin: 0;
  padding: 0;
  background: transparent;
}

.markdown-table-wrapper {
  margin: 0.5em 0;
  overflow-x: auto;
}

.markdown-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #333;
  border-radius: 4px;
  overflow: hidden;
}

.markdown-table th,
.markdown-table td {
  padding: 0.5em 1em;
  border: 1px solid #333;
  text-align: left;
}

.markdown-table th {
  background: #2a2a2a;
  font-weight: 600;
}

.markdown-table tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.markdown-link {
  color: #4a9eff;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.markdown-link:hover {
  border-bottom-color: #4a9eff;
}

.markdown-message img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 0.5em 0;
}

.markdown-message pre {
  margin: 0.5em 0;
}

/* 用户消息中的 Markdown 样式调整 */
.markdown-message-user .markdown-inline-code {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.markdown-message-user .markdown-code-block {
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.1);
}

/* 确保代码块在深色背景上可见 */
.markdown-message-assistant .markdown-code-block {
  background: #1e1e1e;
}

